home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / librw / RWTPtrMapIterator.z / RWTPtrMapIterator
Encoding:
Text File  |  2002-10-03  |  7.2 KB  |  199 lines

  1.  
  2.  
  3.  
  4. RRRRWWWWTTTTPPPPttttrrrrMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))                                RRRRWWWWTTTTPPPPttttrrrrMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))
  5.  
  6.  
  7.  
  8. NNNNaaaammmmeeee
  9.      RWTPtrMapIterator<K,T,C> - Rogue Wave library class
  10.  
  11. SSSSyyyynnnnooooppppssssiiiissss
  12.               #include<rw/tpmap.h>
  13.  
  14.  
  15.  
  16.               RWTPMap<K,T,C> map;
  17.           RWTPMapIterator<K,T,C> itr(map);
  18.  
  19. SSSSttttaaaannnnddddaaaarrrrdddd CCCC++++++++ LLLLiiiibbbbrrrraaaarrrryyyy DDDDeeeeppppeeeennnnddddeeeennnntttt!!!!
  20.      RRRRWWWWTTTTPPPPttttrrrrMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr requires the Standard C++ Library.
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
  28.      RRRRWWWWTTTTPPPPrrrrttttMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr is supplied with Tools 7 to provide an iterator
  29.      interface to the new Standard Library based collections that has backward
  30.      compatibility with the container iterators provided in Tools 6. The order
  31.      of iteration over an RRRRWWWWTTTTPPPPttttrrrrMMMMaaaapppp is dependent on the comparator object
  32.      supplied as applied to the key values of the stored associations.  The
  33.      current item referenced by this iterator is undefined after construction
  34.      or after a call to rrrreeeesssseeeetttt(((()))).  The iterator becomes valid after being
  35.      advanced with either a preincrement or ooooppppeeeerrrraaaattttoooorrrr(((()))).  For both ooooppppeeeerrrraaaattttoooorrrr++++++++
  36.      and ooooppppeeeerrrraaaattttoooorrrr(((()))), iterating past the last element will return a value
  37.      equivalent to boolean ffffaaaallllsssseeee.  Continued increments will return a value
  38.      equivalent to ffffaaaallllsssseeee until rrrreeeesssseeeetttt(((()))) is called.
  39.  
  40. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
  41.      None
  42.  
  43. EEEExxxxaaaammmmpppplllleeeessss
  44.               #include<rw/tpmap.h>
  45.  
  46.  
  47.  
  48.               #include<iostream.h>
  49.           #include<rw/cstring.h>
  50.           int main(){
  51.              RWTPtrMap<RWCString,int,less<RWCString> > age;
  52.              RWTPtrMapIterator<RWCString,int,less<RWCString> > itr(age);
  53.           age.insert(new RWCString("John") ,new int(30));
  54.              age.insert(new RWCString("Steve"),new int(17));
  55.              age.insert(new RWCString("Mark") ,new int(24));
  56.           //Insertion is rejected, no duplicates allowed
  57.              age.insert(new RWCString("Steve"),new int(24));
  58.           for(;itr();)
  59.                cout << *itr.key() << "'s age is " << *itr.value() << endl;
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. RRRRWWWWTTTTPPPPttttrrrrMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))                                RRRRWWWWTTTTPPPPttttrrrrMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))
  71.  
  72.  
  73.  
  74.                  return 0;
  75.  
  76.  
  77.  
  78.               }
  79.           Program Output
  80.           John's age is 30
  81.           Mark's age is 24
  82.           Steve's age is 17
  83.  
  84. PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss
  85.               RRRRWWWWTTTTPPPPttttrrrrMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr<<<<KKKK,,,,TTTT,,,,CCCC>>>>(const RWTPtrMap<K,T,C>& rwm);
  86.  
  87.  
  88.      Creates an iterator for the map rrrrwwwwmmmm.  The iterator begins in an undefined
  89.      state and must be advanced before the first element will be accessible
  90.  
  91. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr OOOOppppeeeerrrraaaattttoooorrrrssss
  92.               K*
  93.           ooooppppeeeerrrraaaattttoooorrrr(((())))();
  94.  
  95.  
  96.      Advances self to the next element, dereferences the resulting iterator
  97.      and returns its key.  If the iterator has advanced past the last item in
  98.      the container,  the element returned will be a nnnniiiillll pointer equivalent to
  99.      boolean ffffaaaallllsssseeee.
  100.  
  101.               RWBoolean
  102.           ooooppppeeeerrrraaaattttoooorrrr++++++++();
  103.  
  104.  
  105.      Advances self to the next element.  If the iterator has been reset or
  106.      just created self will now reference the first element.  If, before
  107.      iteration, self referenced the last association in the multimap, self
  108.      will now point to an undefined value and a value equivalent to ffffaaaallllsssseeee will
  109.      be returned.  Otherwise, a value equivalent to ttttrrrruuuueeee is returned. Note: no
  110.      post-increment operator is provided.
  111.  
  112. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
  113.               RWTPtrMap<K,T,C>*
  114.           ccccoooonnnnttttaaaaiiiinnnneeeerrrr(((()))) const;
  115.  
  116.  
  117.      Returns a pointer to the collection being iterated over.
  118.  
  119.               K*
  120.           kkkkeeeeyyyy() const;
  121.  
  122.  
  123.      Returns the key portion of the association currently referenced by self.
  124.      Undefined if self is not referencing a value within the map.
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. RRRRWWWWTTTTPPPPttttrrrrMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))                                RRRRWWWWTTTTPPPPttttrrrrMMMMaaaappppIIIItttteeeerrrraaaattttoooorrrr((((3333CCCC++++++++))))
  137.  
  138.  
  139.  
  140.               void
  141.           rrrreeeesssseeeetttt();
  142.           void
  143.           rrrreeeesssseeeetttt(RWTPtrMap<K,T,C>& h);
  144.  
  145.  
  146.      Resets the iterator so that after being advanced it will reference the
  147.      first element of the collection.  Using rrrreeeesssseeeetttt(((()))) with no argument will
  148.      reset the iterator on the current container.  Supplying a RRRRWWWWTTTTPPPPttttrrrrMMMMaaaapppp to
  149.      rrrreeeesssseeeetttt(((()))) will reset the iterator on that container.
  150.  
  151.               T*
  152.           vvvvaaaalllluuuueeee();
  153.  
  154.  
  155.      Returns the value portion of the association pointed to by self.
  156.      Undefined if self is not referencing a value within the map.
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.